﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Diagnostics;
using System.Xml;
using System.IO;
using System.ServiceModel.Channels;
using System.Runtime.Serialization.Json;
using System.ServiceModel;
using System.Reflection;
using System.Threading;

namespace Spike.ServiceFramework.ServiceModel.Registration
{
    public class ClientRegistrationBehavior : RegistrationBehavior
    {
        [ConfigurationProperty("clientName", IsRequired = true)]
        public string ClientName
        {
            get { return (string)base["clientName"]; }
            set { base["clientName"] = value; }
        }

        [ConfigurationProperty("clientVersion", IsRequired = true)]
        public string ClientVersion
        {
            get { return (string)base["clientVersion"]; }
            set { base["clientVersion"] = value; }
        }

        internal void ApplyRegistration(Message request)
        {
            request.Headers.Add(MessageHeader.CreateHeader(HEADER_APPLICATION, HEADER_NAMESPACE, new ClientApplication { Name = ClientName, Version = ClientVersion }));            
        }
    }
}
